package com.syslog.web;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.util.AJAXResultMessage;
import com.common.util.ExtjsPageable;
import com.syslog.entity.Syslog;
import com.syslog.service.ISyslogService;

@Controller
@RequestMapping(value="/syslog")
public class SyslogController 
{
	@Autowired
	private ISyslogService syslogService;
	
//	@SystemServiceLog("保存或修改角色")
//	@RequestMapping(value="/saveOrUpdate")
//	public @ResponseBody AJAXResultMessage saveOrUpdate(Syslog syslog) 
//	{
//		try {
//			syslogService.saveOrUpdate(syslog);
//    		return new AJAXResultMessage(true,"操作成功!");
//	    } catch (Exception e) {
//	    	e.printStackTrace();
//	        return new AJAXResultMessage(false,"操作失败!");
//	    }
//	}
	
	@RequestMapping(value = "/deleteSyslogs")
    public @ResponseBody AJAXResultMessage delete(Long[] ids) {
    	try {
    		List<Long> idlists=Arrays.asList(ids);
    		if(null!=idlists) {
    			syslogService.delete(idlists);
    		}    		
    		return new AJAXResultMessage(true,"操作成功!");
	    } catch (Exception e) {
	    	e.printStackTrace();
	        return new AJAXResultMessage(false,"操作失败!");
	    }
    }
	@RequestMapping(value = "/delete")
    public @ResponseBody AJAXResultMessage delete(Long id) {
    	try {
    		syslogService.delete(id);
    		return new AJAXResultMessage(true,"操作成功!");
	    } catch (Exception e) {
	    	e.printStackTrace();
	        return new AJAXResultMessage(false,"操作失败!");
	    }
    }
//	@RequestMapping("/findOne")
//	public @ResponseBody SyslogDTO findOne(Long id) {
//		return syslogService.findOne(id);
//	}
	
	@RequestMapping("/findPage")
	public @ResponseBody Page<Syslog> findAll(Syslog syslog,ExtjsPageable pageable) 
	{
		Page<Syslog> page =syslogService.findPage(Syslog.getSpecification(syslog), pageable.getPageable());		
		return page;
	}

}
